package com.usian.controller;

import com.usian.feign.SearchItemFeign;
import com.usian.pojo.SearchItem;
import com.usian.utils.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RequestMapping("frontend/searchItem")
@RestController
public class SearchItemController {
    @Autowired
    private SearchItemFeign searchItemFeign;

    @RequestMapping("importAll")
    public Result importAll(){
        try {
            searchItemFeign.importAll();
            return Result.ok();
        }catch (Exception e){
            e.printStackTrace();
            return Result.error("导入失败");
        }

    }

    @RequestMapping("list")
    public List<SearchItem>selectByQ(@RequestParam String q,@RequestParam(defaultValue = "1") Integer page,@RequestParam(defaultValue = "20") Integer pagesize){
        return searchItemFeign.selectByQ(q,page,pagesize);

    }
}
